<?php
	$statePageMainImage = get_post_meta($post->ID, 'statePageMainImage', true);
	$statePageStateName = get_post_meta($post->ID, 'statePageStateName', true);
	$statePageCons = get_post_meta($post->ID, 'statePagePros', true);
	$statePagePros = get_post_meta($post->ID, 'statePageCons', true);

	if (get_post_meta($post->ID, 'statePageStateName', true) == 'New York') {
		$statePageStateAbbr = 'NY';
		$stateTag = 'new-york';
		$statePageGalleryTag = 'new-york';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'California') {
		$statePageStateAbbr = 'CA';
		$stateTag = 'california';
		$statePageGalleryTag = 'california';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Colorado') {
		$statePageStateAbbr = 'CO';
		$stateTag = 'colorado';
		$statePageGalleryTag = 'colorado';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Alabama') {
		$statePageStateAbbr = 'AL';
		$stateTag = 'alabama';
		$statePageGalleryTag = 'alabama';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Florida') {
		$statePageStateAbbr = 'FL';
		$stateTag = 'florida';
		$statePageGalleryTag = 'florida';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Illinois') {
		$statePageStateAbbr = 'IL';
		$stateTag = 'illinois';
		$statePageGalleryTag = 'illinois';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Kentucky') {
		$statePageStateAbbr = 'KY';
		$stateTag = 'kentucky';
		$statePageGalleryTag = 'kentucky';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Massachusetts') {
		$statePageStateAbbr = 'MA';
		$stateTag = 'massachusetts';
		$statePageGalleryTag = 'massachusetts';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Missouri') {
		$statePageStateAbbr = 'MO';
		$stateTag = 'missouri';
		$statePageGalleryTag = 'missouri';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'New Hampshire') {
		$statePageStateAbbr = 'NH';
		$stateTag = 'new-hampshire';
		$statePageGalleryTag = 'new-hampshire';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'North Carolina') {
		$statePageStateAbbr = 'NC';
		$stateTag = 'north-carolina';
		$statePageGalleryTag = 'north-carolina';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Oregon') {
		$statePageStateAbbr = 'OR';
		$stateTag = 'oregon';
		$statePageGalleryTag = 'oregon';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'South Dakota') {
		$statePageStateAbbr = 'SD';
		$stateTag = 'south-dakota';
		$statePageGalleryTag = 'south-dakota';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Vermont') {
		$statePageStateAbbr = 'VT';
		$stateTag = 'vermont';
		$statePageGalleryTag = 'vermont';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Wisconsin') {
		$statePageStateAbbr = 'WI';
		$stateTag = 'wisconsin';
		$statePageGalleryTag = 'wisconsin';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Alaska') {
		$statePageStateAbbr = 'AK';
		$stateTag = 'alaska';
		$statePageGalleryTag = 'alaska';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Georgia') {
		$statePageStateAbbr = 'GA';
		$stateTag = 'georgia';
		$statePageGalleryTag = 'georgia';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Indiana') {
		$statePageStateAbbr = 'IN';
		$stateTag = 'indiana';
		$statePageGalleryTag = 'indiana';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Louisiana') {
		$statePageStateAbbr = 'LA';
		$stateTag = 'louisiana';
		$statePageGalleryTag = 'louisiana';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Michigan') {
		$statePageStateAbbr = 'MI';
		$stateTag = 'michigan';
		$statePageGalleryTag = 'michigan';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Montana') {
		$statePageStateAbbr = 'MT';
		$stateTag = 'montana';
		$statePageGalleryTag = 'montana';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'New Jersey') {
		$statePageStateAbbr = 'NJ';
		$stateTag = 'new-jersey';
		$statePageGalleryTag = 'new-jersey';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'North Dakota') {
		$statePageStateAbbr = 'ND';
		$stateTag = 'north-dakota';
		$statePageGalleryTag = 'north-dakota';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Pennsylvania') {
		$statePageStateAbbr = 'PA';
		$stateTag = 'pennsylvania';
		$statePageGalleryTag = 'pennsylvania';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Tennessee') {
		$statePageStateAbbr = 'TN';
		$stateTag = 'tennessee';
		$statePageGalleryTag = 'tennessee';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Virginia') {
		$statePageStateAbbr = 'VA';
		$stateTag = 'virginia';
		$statePageGalleryTag = 'virginia';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Wyoming') {
		$statePageStateAbbr = 'WY';
		$stateTag = 'wyoming';
		$statePageGalleryTag = 'wyoming';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Arizona') {
		$statePageStateAbbr = 'AZ';
		$stateTag = 'arizona';
		$statePageGalleryTag = 'arizona';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Connecticut') {
		$statePageStateAbbr = 'CT';
		$stateTag = 'connecticut';
		$statePageGalleryTag = 'connecticut';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Hawaii') {
		$statePageStateAbbr = 'HI';
		$stateTag = 'hawaii';
		$statePageGalleryTag = 'hawaii';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Iowa') {
		$statePageStateAbbr = 'IA';
		$stateTag = 'iowa';
		$statePageGalleryTag = 'iowa';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Maine') {
		$statePageStateAbbr = 'ME';
		$stateTag = 'maine';
		$statePageGalleryTag = 'maine';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Minnesota') {
		$statePageStateAbbr = 'MN';
		$stateTag = 'minnesota';
		$statePageGalleryTag = 'minnesota';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Nebraska') {
		$statePageStateAbbr = 'NE';
		$stateTag = 'nebraska';
		$statePageGalleryTag = 'nebraska';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'New Mexico') {
		$statePageStateAbbr = 'NM';
		$stateTag = 'new-mexico';
		$statePageGalleryTag = 'new-mexico';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Ohio') {
		$statePageStateAbbr = 'OH';
		$stateTag = 'ohio';
		$statePageGalleryTag = 'ohio';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Rhode Island') {
		$statePageStateAbbr = 'RI';
		$stateTag = 'rhode-island';
		$statePageGalleryTag = 'rhode-island';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Texas') {
		$statePageStateAbbr = 'TX';
		$stateTag = 'texas';
		$statePageGalleryTag = 'texas';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Washington') {
		$statePageStateAbbr = 'WA';
		$stateTag = 'washington';
		$statePageGalleryTag = 'washington';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Arkansas') {
		$statePageStateAbbr = 'AR';
		$stateTag = 'arkansas';
		$statePageGalleryTag = 'arkansas';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Idaho') {
		$statePageStateAbbr = 'ID';
		$stateTag = 'idaho';
		$statePageGalleryTag = 'idaho';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Kansas') {
		$statePageStateAbbr = 'KS';
		$stateTag = 'kansas';
		$statePageGalleryTag = 'kansas';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Maryland') {
		$statePageStateAbbr = 'MD';
		$stateTag = 'maryland';
		$statePageGalleryTag = 'maryland';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Mississippi') {
		$statePageStateAbbr = 'MS';
		$stateTag = 'mississippi';
		$statePageGalleryTag = 'mississippi';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Nevada') {
		$statePageStateAbbr = 'NV';
		$stateTag = 'nevada';
		$statePageGalleryTag = 'nevada';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Oklahoma') {
		$statePageStateAbbr = 'OK';
		$stateTag = 'oklahoma';
		$statePageGalleryTag = 'oklahoma';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'South Carolina') {
		$statePageStateAbbr = 'SC';
		$stateTag = 'south-carolina';
		$statePageGalleryTag = 'south-carolina';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'Utah') {
		$statePageStateAbbr = 'UT';
		$stateTag = 'utah';
		$statePageGalleryTag = 'utah';
	} elseif (get_post_meta($post->ID, 'statePageStateName', true) == 'West Virginia') {
		$statePageStateAbbr = 'WV';
		$stateTag = 'west-virgina';
		$statePageGalleryTag = 'west-virginia';
	}
	
	$hastags = get_the_tags();
?>

	<style>
		#content h2.statePageBlueTitle { display:block;height:40px;line-height:40px;margin:0px;margin-bottom:10px;padding-left:10px;background:#022d55;color:#ffffff;font-size:20px;font-weight:bold; }
#content h3.statePageOrangeTitle { display:block;height:40px;line-height:40px;margin:0px;margin-bottom:10px;padding-left:10px;background:#e77d1d;color:#ffffff;font-size:20px;font-weight:bold; }

#content .statePageCityBox { width:200px;padding:10px;border:#cccccc 1px solid;background:#f2f2f2;float:right;margin:0px;margin-left:20px;margin-bottom:10px; }
	#content .statePageCityBox h4 { font-size:15px;font-weight:bold;line-height:15px;margin:0px;margin-bottom:10px; }
    #content .statePageCityBox ul { list-style:none;padding:0px;margin:0px; }
    
#content .statePageLeft { width:325px;float:left;margin:0px; }
#content .statePageRight { width:325px;float:right;margin:0px; }

#content ul.statePagePostList { list-style:none;padding:0px;padding-left:10px;margin:0px;margin-bottom:10px; }

#content .statePageInstallationBlock { width:220px;height:250px;padding:0px;float:left;margin:0px;text-align:center; }
	#content .statePageInstallationBlock:hover { background:#f2f2f2; }
    #content .statePageInstallationBlock a { display:block;width:200px;padding:10px;text-decoration:none;color:#002d55; }
    	#content .statePageInstallationBlock a img { width:200px;height:150px;margin-bottom:10px; }
        #content .statePageInstallationBlock a .statePageInstallationCustomer { font-weight:bold;font-size:14px; }
        #content .statePageInstallationBlock a .statePageInstallationLocation { font-weight:bold;color:#e77d1d; }
        #content .statePageInstallationBlock a .statePageInstallationDate { color:#000000;font-style:italic; }
	</style>
    
    <h2 class="statePageBlueTitle"><?php the_title(); ?></h2>
    <?php include ('socialbuttons.php'); ?>
    <img src="<?=$statePageMainImage?>" width="300" height="225" style="border:#f2f2f2 3px solid; float:right;margin:0px;margin-left:20px;margin-bottom:20px;" />
	<?php the_content(); ?>
    
    <div style="width:100%;height:20px;margin:0px;clear:both;"></div>
        
    <?php if (get_post_meta($post->ID, 'statePagePros', true)) { ?>
    <h3 class="statePageOrangeTitle">Why Solar Is Great In <?=$statePageStateName?></h3>
		<?php // Get The Related Solar Cities
		query_posts('tag=' .$stateTag . '&showposts=-1&cat=312');
		if (have_posts()) { ?>
        	<div class="statePageCityBox">
				<h4>Key Solar Cities In <?=$statePageStateAbbr?>:</h4>
				<ul>
					<?php while (have_posts()) : the_post(); ?>
						<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
					<?php endwhile; wp_reset_query(); ?>
				</ul>
            </div>
		<?php } ?>
    <p><?=$statePagePros?></p>
    <?php } ?>
    
    <?php if (get_post_meta($post->ID, 'statePageCons', true)) { ?>
    <h3 class="statePageOrangeTitle">Challenges For Solar In <?=$statePageStateName?></h3>
    <p><?=$statePageCons?></p>
    <?php } ?>

	<?php // Get The Related Press Releases
		query_posts('tag=' .$stateTag . '&showposts=-1&cat=11');
		if (have_posts()) { ?>
			<h3 class="statePageOrangeTitle"><?=$statePageStateName?> Solar News</h3>
			<ul class="statePagePostList">
			<?php while (have_posts()) : the_post(); ?>
				<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
			<?php endwhile; wp_reset_query(); ?>
			</ul>	
		<?php } ?>
    
    <?php // Get The Related Press Releases
		query_posts('tag=' .$stateTag . '&showposts=-1&cat=10');
		if (have_posts()) { ?>
			<h3 class="statePageOrangeTitle"><?=$statePageStateName?> Solar Installations</h3>
			<?php while (have_posts()) : the_post(); ?>
				<div class="statePageInstallationBlock">
					<a href="<?php the_permalink(); ?>">
						<?php the_post_thumbnail(); ?>
						<span class="statePageInstallationCustomer"><?php meta('RPCustomer'); ?></span><br />
						<span class="statePageInstallationLocation"><?php meta('RPLocation'); ?></span><br />
						<span class="statePageInstallationDate"><?php meta('RPDate'); ?></span>
					</a>
				</div>
    			<?php endwhile; wp_reset_query(); ?>
    	<?php } ?>
    
    <div class="statePageLeft">
    	<?php // Get The Related Solar Agencies
		query_posts('tag=' .$stateTag . '&showposts=-1&cat=313');
		if (have_posts()) { ?>
			<h3 class="statePageOrangeTitle"><?=$statePageStateName?> Solar Agencies</h3>
			<ul class="statePagePostList">
			<?php while (have_posts()) : the_post(); ?>
				<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
			<?php endwhile; wp_reset_query(); ?>
			</ul>	
		<?php } ?>
    </div>
    
    <div class="statePageRight">
    	<?php // Get The Related Solar Incentives
		query_posts('tag=' .$stateTag . '&showposts=-1&cat=69');
		if (have_posts()) { ?>
			<h3 class="statePageOrangeTitle"><?=$statePageStateName?> Solar Incentives</h3>
			<ul class="statePagePostList">
			<?php while (have_posts()) : the_post(); ?>
				<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
			<?php endwhile; wp_reset_query(); ?>
			</ul>	
		<?php } ?>
    </div>
